/******************************************************************************
 * * setting_phone.c - implementation of phone setting functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "setting_global.h"

Setting_Phone_Setting_Mng_t g_SettingPhoneSettingMng;
VOID                        *gp_SettingPhoneDisplayCurUIDesc              = NULL; // Current UI description
VOID                        *gp_SettingPhoneSettingsCuContainerListUIDesc = NULL; // Current Setting Phone Settings UI description
VOID                        *gp_SettingKeyguardSettingsCurUIDesc          = NULL; // Current Setting Keyguard Settings UI description
MMI_Modem_PLMN_Info         *SettingPhonePlmnList                         = NULL;
TIMER_ID                    g_SettingDoneTimer;

/**
 * sub-module entry
 * param (in) void
 * return  void
 */
VOID Setting_Phone_Main(VOID)
{
    // init manage variable
}

/**
 * sub-module event handler
 * param (in) void
 * return  void
 */
VOID Setting_Phone_Event_handle(VOID)
{
    // event and message dispatch
}

/**
 * initiate phone sub-module
 * param (in) NvPara: Setting_NVM_Para_t
 * return  void
 */
VOID Setting_Phone_Init_Req(NV_UI_Settings_t *pNvPara)
{
    // init manage variable
    UINT8 i;

    g_SettingPhoneSettingMng.CurrentLanguage   = (SETTING_LANGUAGE)(pNvPara->PhoneSetting.CurrentLanguage);
    g_SettingPhoneSettingMng.AutoGuardOn       = (BOOL)(pNvPara->PhoneSetting.AutoGuardOn);
    g_SettingPhoneSettingMng.AutoGuardDelay    = (UINT16)(pNvPara->PhoneSetting.AutoGuardDelay);
    g_SettingPhoneSettingMng.KeyguardOn        = (SETTING_STANDBY_SCREEN)(pNvPara->PhoneSetting.KeyguardOn);
    g_SettingPhoneSettingMng.PlmnSearchMode[0] = (SETTING_PLMN_SEARCH_MODE)(pNvPara->PhoneSetting.PlmnSearchMode[0]);
    g_SettingPhoneSettingMng.PlmnSearchMode[1] = (SETTING_PLMN_SEARCH_MODE)(pNvPara->PhoneSetting.PlmnSearchMode[1]);
    g_SettingPhoneSettingMng.StartupToneOn     = (BOOL)(pNvPara->PhoneSetting.StartupToneOn);
    g_SettingPhoneSettingMng.FlightModeOn      = (BOOL)(pNvPara->PhoneSetting.FlightModeOn);
    g_SettingPhoneSettingMng.WelcomeNoteOn     = (BOOL)(pNvPara->PhoneSetting.WelcomeNoteOn);

    for (i = 0; i < SETTING_MAX_WELCOME_NOTE_STR_LEN; i++)
    {
        g_SettingPhoneSettingMng.WelcomeNote[i] = (INT8)(pNvPara->PhoneSetting.WelcomeNote[i]);
    }

    if (SETTING_LANGUAGE_EN == g_SettingPhoneSettingMng.CurrentLanguage)
    {
        lv_lang_set(UI_LANG_EN);
    }
    else
    {
        lv_lang_set(UI_LANG_CH);
    }

    g_SettingPhoneSettingMng.PlmnSearchStat = SETTING_PLMN_SEARCH_NONE;
}

/**
 * get phone setting
 * param (out) PhoneSetting: If_Setting_Phone_Setting_t, alloc and free by caller
 * return  void
 */
VOID Setting_Get_Phone_Setting_Req(Setting_Phone_Setting_t *PhoneSetting)
{
    NV_UI_Settings_t *pNvUiSetting;

    // malloc memory for NVM reading buffer
    pNvUiSetting = Hal_Mem_Alloc(sizeof(NV_UI_Settings_t));

    // read NVM
    UI_NV_Read_Req(NV_SECTION_UI_SETTINGS, 0, sizeof(NV_UI_Settings_t), (UINT8 *)pNvUiSetting);

    // fill para to PhoneSetting
    PhoneSetting->ChangeMark = 0;

    if ((FALSE == g_SettingSimStatus[MMI_MODEM_SIM_1]) && (FALSE == g_SettingSimStatus[MMI_MODEM_SIM_2]))
    {
        PhoneSetting->ChangeMark &= ~IF_SETTING_CHANGE_MARK_DUAL_STAND_BY;
    }
    else
    {
        PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_DUAL_STAND_BY;
        if (SETTING_DEFAULT_DULT_SIM == pNvUiSetting->DualSimSetting.DefaultSim4Standby)
        {
            PhoneSetting->DualStandby = IF_SETTING_DUAL_SIM_STANDBY;
        }
        else if (SETTING_DEFAULT_SIM1 == pNvUiSetting->DualSimSetting.DefaultSim4Standby)
        {
            PhoneSetting->DualStandby = IF_SETTING_SIM_1_STANDBY;
        }
        else if (SETTING_DEFAULT_SIM2 == pNvUiSetting->DualSimSetting.DefaultSim4Standby)
        {
            PhoneSetting->DualStandby = IF_SETTING_SIM_2_STANDBY;
        }

        PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_NAME_OF_SIM1;
        Hal_Mem_Copy(PhoneSetting->NameOfSIM1, pNvUiSetting->DualSimSetting.SimName[0], NV_SETTING_MAX_SIM_NAME_LEN);

        PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_NAME_OF_SIM2;
        Hal_Mem_Copy(PhoneSetting->NameOfSIM2, pNvUiSetting->DualSimSetting.SimName[1], NV_SETTING_MAX_SIM_NAME_LEN);
    }

    PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_WALL_PAPER;
    PhoneSetting->WallPaper   = SettingWallPaterList[pNvUiSetting->DisplaySetting.CurrentWallPaperIndex].WallPaper;

    PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_TIME_DISPLAY;
    if (SETTING_TIME_HIDE == pNvUiSetting->TimeSetting.TimeDisplay)
    {
        PhoneSetting->TimeDisplay.TimeDisplay = IF_SETTING_TIME_HIDE;
    }
    else
    {
        PhoneSetting->TimeDisplay.TimeDisplay = IF_SETTING_TIME_SHOW;
    }
    if (SETTING_TIME_FORMAT_12H == pNvUiSetting->TimeSetting.TimeFormat)
    {
        PhoneSetting->TimeDisplay.TimeFormat = IF_SETTING_TIME_FORMAT_12H;
    }
    else
    {
        PhoneSetting->TimeDisplay.TimeFormat = IF_SETTING_TIME_FORMAT_24H;
    }

    PhoneSetting->ChangeMark     |= IF_SETTING_CHANGE_MARK_CURRENT_LANGUAGE;
    if (0 == pNvUiSetting->PhoneSetting.CurrentLanguage)
    {
        PhoneSetting->CurrentLanguage = SETTING_LANGUAGE_EN;
    }
    else if (1 == pNvUiSetting->PhoneSetting.CurrentLanguage)
    {
        PhoneSetting->CurrentLanguage = SETTING_LANGUAGE_CN_SIMPLE;
    }
    else if (2 == pNvUiSetting->PhoneSetting.CurrentLanguage)
    {
        PhoneSetting->CurrentLanguage = SETTING_LANGUAGE_CN_TRADITIONAL;
    }

    PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_AUTO_GUARD_ON;
    PhoneSetting->AutoGuardOn = pNvUiSetting->PhoneSetting.AutoGuardOn;

    PhoneSetting->ChangeMark    |= IF_SETTING_CHANGE_MARK_AUTO_GUARD_DELAY;
    PhoneSetting->AutoGuardDelay = pNvUiSetting->PhoneSetting.AutoGuardDelay;

    PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_KEYGUARD_ON;
    PhoneSetting->KeyguardOn  = pNvUiSetting->PhoneSetting.KeyguardOn;

    PhoneSetting->ChangeMark   |= IF_SETTING_CHANGE_MARK_STARTUP_TONE_ON;
    PhoneSetting->StartupToneOn = pNvUiSetting->PhoneSetting.StartupToneOn;

    PhoneSetting->ChangeMark   |= IF_SETTING_CHANGE_MARK_WELCOME_NOTE_ON;
    PhoneSetting->WelcomeNoteOn = pNvUiSetting->PhoneSetting.WelcomeNoteOn;

    if (TRUE == PhoneSetting->WelcomeNoteOn)
    {
        PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_WELCOME_NOTE;
        Hal_Mem_Copy(PhoneSetting->WelcomeNote,
                     pNvUiSetting->PhoneSetting.WelcomeNote,
                     NV_SETTING_MAX_WELCOME_NOTE_STR_LEN);
    }

    // free the nvm reading buffer
    Hal_Mem_Free(pNvUiSetting);
} /* Setting_Get_Phone_Setting_Req */

/**
 * Set current language
 * param (in) CurrentLanguage: SETTING_LANGUAGE
 * return void:
 */
VOID Setting_Set_Language(SETTING_LANGUAGE CurrentLanguage)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.CurrentLanguage = CurrentLanguage;

    // nv write
    nvData = (UINT8)CurrentLanguage;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET, 1, &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark      = IF_SETTING_CHANGE_MARK_CURRENT_LANGUAGE;
    PhoneSettingChg->CurrentLanguage = g_SettingPhoneSettingMng.CurrentLanguage;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set auto guard on/off
 * param (in) AutoGuardOn: BOOL
 * return void:
 */
VOID Setting_Set_Auto_Guard_On(BOOL AutoGuardOn)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.AutoGuardOn = AutoGuardOn;

    // nv write
    nvData = (UINT8)g_SettingPhoneSettingMng.AutoGuardOn;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET + 1, 1, &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark  = IF_SETTING_CHANGE_MARK_AUTO_GUARD_ON;
    PhoneSettingChg->AutoGuardOn = g_SettingPhoneSettingMng.AutoGuardOn;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set auto guard delay time
 * param (in) AutoGuardDelay: UINT16
 * return void:
 */
VOID Setting_Set_Auto_Guard_Delay(UINT16 AutoGuardDelay)
{
    UINT8                   nvData[2];
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.AutoGuardDelay = AutoGuardDelay;

    // nv write
    Hal_Mem_Copy(nvData, &AutoGuardDelay, 2);
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET + 2, 2, nvData);

    // inform framework
    PhoneSettingChg->ChangeMark     = IF_SETTING_CHANGE_MARK_AUTO_GUARD_DELAY;
    PhoneSettingChg->AutoGuardDelay = g_SettingPhoneSettingMng.AutoGuardDelay;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set keyguard on/off
 * param (in) KeyguardOn: BOOL
 * return void:
 */
VOID Setting_Set_Keyguard_On(BOOL KeyguardOn)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.KeyguardOn = KeyguardOn;

    // nv write
    nvData = (UINT8)KeyguardOn;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET + 4, 1, &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark = IF_SETTING_CHANGE_MARK_KEYGUARD_ON;
    PhoneSettingChg->KeyguardOn = KeyguardOn;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set start-up tone on/off
 * param (in) StartupToneOn: BOOL
 * return void:
 */
VOID Setting_Set_Startup_Tone_On(BOOL StartupToneOn)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.StartupToneOn = StartupToneOn;

    // nv write
    nvData = (UINT8)StartupToneOn;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET + 7, 1, &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark    = IF_SETTING_CHANGE_MARK_STARTUP_TONE_ON;
    PhoneSettingChg->StartupToneOn = StartupToneOn;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set Flight Mode on/off
 * param (in) FlightMode: BOOL
 * return void:
 */
VOID Setting_Set_Flight_Mode_On(BOOL FlightModeOn)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.FlightModeOn = FlightModeOn;

    // nv write
    nvData = (UINT8)FlightModeOn;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS,
                    NV_SETTING_PHONE_SETTING_OFFSET + 9 + SETTING_MAX_WELCOME_NOTE_STR_LEN,
                    1,
                    &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark    = IF_SETTING_CHANGE_MARK_FLIGHT_MODE_ON;
    PhoneSettingChg->FlightModeOn = FlightModeOn;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set Welcome Note display or not
 * param (in) WelcomeNoteOn: BOOL
 * return void:
 */
VOID Setting_Set_Welcome_Note_On(BOOL WelcomeNoteOn)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingPhoneSettingMng.WelcomeNoteOn = WelcomeNoteOn;

    // nv write
    nvData = (UINT8)WelcomeNoteOn;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET + 8, 1, &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark    = IF_SETTING_CHANGE_MARK_WELCOME_NOTE_ON;
    PhoneSettingChg->WelcomeNoteOn = WelcomeNoteOn;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Set plmn search mode
 * param (in) SimId: MMI_MODEM_SIM_ID
 * param (in) PlmnSearchMode: SETTING_PLMN_SEARCH_MODE
 * return void:
 */
VOID Setting_Set_Plmn_Search_Mode(MMI_MODEM_SIM_ID SimId, SETTING_PLMN_SEARCH_MODE PlmnSearchMode)
{
    UINT8 nvData[2];

    // change global variable
    if (MMI_MODEM_SIM_1 == SimId)
    {
        if (SETTING_PLMN_SEARCH_AUTO == PlmnSearchMode)
        {
            g_SettingPhoneSettingMng.PlmnSearchMode[0] = SETTING_PLMN_SEARCH_AUTO;
        }
        else
        {
            g_SettingPhoneSettingMng.PlmnSearchMode[0] = SETTING_PLMN_SEARCH_MANUAL;
        }
    }
    else
    {   // sim2
        if (SETTING_PLMN_SEARCH_AUTO == PlmnSearchMode)
        {
            g_SettingPhoneSettingMng.PlmnSearchMode[1] = SETTING_PLMN_SEARCH_AUTO;
        }
        else
        {
            g_SettingPhoneSettingMng.PlmnSearchMode[1] = SETTING_PLMN_SEARCH_MANUAL;
        }
    }

    // nv write
    nvData[0] = (UINT8)g_SettingPhoneSettingMng.PlmnSearchMode[0];
    nvData[1] = (UINT8)g_SettingPhoneSettingMng.PlmnSearchMode[1];
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_PHONE_SETTING_OFFSET + 5, 2, nvData);
}

/**
 * Set welcom note
 * param (in) WelcomeNote: UINT8*
 * return void:
 */
VOID Setting_Set_Welcome_Note(INT8 *WelcomeNote)
{
    UINT8                   nvData[SETTING_MAX_WELCOME_NOTE_STR_LEN];
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // nv write
    Hal_Mem_Copy((INT8 *)nvData, WelcomeNote, SETTING_MAX_WELCOME_NOTE_STR_LEN);
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS,
                    NV_SETTING_PHONE_SETTING_OFFSET + 9,
                    SETTING_MAX_WELCOME_NOTE_STR_LEN,
                    nvData);

    // inform framework
    PhoneSettingChg->ChangeMark = IF_SETTING_CHANGE_MARK_WELCOME_NOTE;
    Hal_Mem_Copy(PhoneSettingChg->WelcomeNote, WelcomeNote, SETTING_MAX_WELCOME_NOTE_STR_LEN);
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Translate language to Txtid
 * param (in) Back
 * return TxtId: UINT16
 */
UINT16 Setting_Current_Language_To_Txtid(SETTING_LANGUAGE CurrentLanguage)
{
    UINT16 TxtId = LV_LANG_TXT_ID_NONE;

    switch (CurrentLanguage)
    {
    case SETTING_LANGUAGE_EN:
        TxtId = PHONE_TEXT_ID_ENGLISH;
        break;

    case SETTING_LANGUAGE_CN_SIMPLE:
        TxtId = PHONE_TEXT_ID_CH;
        break;

    default:
        break;
    }

    return(TxtId);
}

/**
 *
 * Callback of Display_Setting_Language_Settings, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Language_Settings_Destroy(VOID *pPara)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc = NULL;

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)pPara;

    Hal_Mem_Free(NormalLstOnlyDesc->List.ButtonList);
    Hal_Mem_Free(NormalLstOnlyDesc);
}

VOID Display_Setting_Language_Setting_English_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;
        NormalContainerListDesc->ContList.ContainerList[0].u.Label2.TxtId = PHONE_TEXT_ID_ENGLISH;

        Setting_Set_Language(SETTING_LANGUAGE_EN);
        lv_lang_set(UI_LANG_EN);
        Display_Setting_Done(ACT_ID_SETTING_LANGUAGE_SETTING, PHONE_TEXT_ID_ENGLISH, ACT_ID_SETTING_PHONE_SETTINGS);
    }
}

VOID Display_Setting_Language_Setting_CH_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;
        NormalContainerListDesc->ContList.ContainerList[0].u.Label2.TxtId = PHONE_TEXT_ID_CH;

        Setting_Set_Language(SETTING_LANGUAGE_CN_SIMPLE);
        lv_lang_set(UI_LANG_CH);
        Display_Setting_Done(ACT_ID_SETTING_LANGUAGE_SETTING, PHONE_TEXT_ID_CH, ACT_ID_SETTING_PHONE_SETTINGS);
    }
}

/**
 *
 * Display_Setting_Language_Setting
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Language_Setting_Key_Cb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;

    if (KEY_DOWN == key_val)
    {
        NormalLstOnlyDesc->List.Index++;
        NormalLstOnlyDesc->List.Index %= NormalLstOnlyDesc->List.ListButtonCnt;
        return(0);
    }
    else if (KEY_UP == key_val)
    {
        NormalLstOnlyDesc->List.Index += NormalLstOnlyDesc->List.ListButtonCnt;
        NormalLstOnlyDesc->List.Index--;
        NormalLstOnlyDesc->List.Index %= NormalLstOnlyDesc->List.ListButtonCnt;
        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Language_Setting
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Language_Setting(VOID)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_LANGUAGE;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    if (SETTING_LANGUAGE_EN == g_SettingPhoneSettingMng.CurrentLanguage)
    {
        NormalLstOnlyDesc->List.Index = 0;
    }
    else if (SETTING_LANGUAGE_CN_SIMPLE == g_SettingPhoneSettingMng.CurrentLanguage)
    {
        NormalLstOnlyDesc->List.Index = 1;
    }

    NormalLstOnlyDesc->List.ListButtonCnt = 2;
    NormalLstOnlyDesc->List.ButtonList    = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);

    NormalLstOnlyDesc->List.ButtonList[0].ButtonIndex = 0;
    NormalLstOnlyDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_ENGLISH;
    NormalLstOnlyDesc->List.ButtonList[0].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[0].ReleaseFun  = Display_Setting_Language_Setting_English_Cb;

    NormalLstOnlyDesc->List.ButtonList[1].ButtonIndex = 1;
    NormalLstOnlyDesc->List.ButtonList[1].TxtId       = PHONE_TEXT_ID_CH;
    NormalLstOnlyDesc->List.ButtonList[1].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[1].ReleaseFun  = Display_Setting_Language_Setting_CH_Cb;

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;

    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Display_Setting_Language_Setting_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_List_Only_Create;
    FuncList.OnDestroy = Display_Setting_Language_Settings_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_LANGUAGE_SETTING, &FuncList, (VOID *)NormalLstOnlyDesc);
    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalLstOnlyDesc;
} /* Display_Setting_Language_Setting */

VOID Display_Setting_Language_Setting_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Language_Setting();
    }
}

/**
 *
 * Callback of Display_Setting_Delay_Setting, on destroy
 * param (in) pNormalTimeDesc: UI_Normal_Time_Desc_t*
 * return void:
 */
VOID Display_Setting_Delay_Setting_Destroy(VOID *pPara)
{
    Hal_Mem_Free(pPara);
}

/**
 *
 * Callback of Display_Setting_Delay_Setting, on restore state
 * param (in) pNormalTimeDesc: UI_Normal_Time_Desc_t*
 * return void:
 */
VOID Display_Setting_Delay_Setting_RestoreState(VOID *pNormalTimeDesc)
{
    gp_SettingPhoneDisplayCurUIDesc = pNormalTimeDesc;
}

/**
 *
 * Callback of Display_Setting_Delay_Setting, on save state
 * param (in) pNormalTimeDesc: UI_Normal_Time_Desc_t*
 * return void:
 */
VOID Display_Setting_Delay_Setting_OnSaveState(VOID *pNormalTimeDesc)
{
    UI_Normal_Time_Desc_t *Desc = pNormalTimeDesc;
    INT8 Buf[3] = {0};

    lv_roller_get_selected_str(Desc->ContTime.Roller1.Roller, Buf, 3);
    Desc->ContTime.Roller1.MidValue = atoi(Buf);
    lv_roller_get_selected_str(Desc->ContTime.Roller2.Roller, Buf, 3);
    Desc->ContTime.Roller2.MidValue = atoi(Buf);
}

/**
 *
 * Callback of Display_Setting_Delay_Setting, KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Delay_Setting_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT16                          AutoGuardDelay;
    UI_Normal_Time_Desc_t           *pNormalTimeDesc          = NULL;
    UI_Normal_Container_List_Desc_t *pNormalContainerListDesc = NULL;

    pNormalTimeDesc = (UI_Normal_Time_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_OK == key_val)
    {
        pNormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingKeyguardSettingsCurUIDesc;
        pNormalContainerListDesc->ContList.ContainerList[pNormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_ON;

        Setting_Set_Auto_Guard_On(TRUE);

        INT8 Buf[3] = {0};
        lv_roller_get_selected_str(pNormalTimeDesc->ContTime.Roller1.Roller, Buf, 3);
        AutoGuardDelay = atoi(Buf) * 60;
        lv_roller_get_selected_str(pNormalTimeDesc->ContTime.Roller2.Roller, Buf, 3);
        AutoGuardDelay += atoi(Buf);
        Setting_Set_Auto_Guard_Delay(AutoGuardDelay);

        Display_Setting_Done(ACT_ID_SETTING_DELAY_SETTING, PHONE_TEXT_ID_SELECT_DELAY_TIME,ACT_ID_SETTING_KEYGUARD_SETTINGS);
        return(1);
    }
    else if (KEY_SOFTRIGHT == key_val)   // BACK
    {
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
} /* Display_Setting_Delay_Setting_KeyCb */


/**
 * display Setting_Delay_Setting
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Delay_Setting(VOID)
{
    Nav_Func_List_t       FuncList;
    UI_Normal_Time_Desc_t *pNormalTimeDesc;

    // Alloc memory for time scroll UI display
    pNormalTimeDesc = Hal_Mem_Alloc(sizeof(UI_Normal_Time_Desc_t));
    Hal_Mem_Set(pNormalTimeDesc, 0, sizeof(UI_Normal_Time_Desc_t));

    // Set the UI description parameters
    pNormalTimeDesc->TitleBar.TxtId      = PHONE_TEXT_ID_SELECT_DELAY_TIME;
    pNormalTimeDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalTimeDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    pNormalTimeDesc->ContTime.Roller1.MidValue = g_SettingPhoneSettingMng.AutoGuardDelay / 60;
    pNormalTimeDesc->ContTime.Roller1.RollerType = UI_ROLLER_TYPE_MINUTE;

    pNormalTimeDesc->ContTime.Roller2.MidValue = g_SettingPhoneSettingMng.AutoGuardDelay % 60;
    pNormalTimeDesc->ContTime.Roller2.RollerType = UI_ROLLER_TYPE_SECOND;

    pNormalTimeDesc->ButtonBar.ButtonL.Valid = FALSE;

    pNormalTimeDesc->ButtonBar.ButtonM.Valid = TRUE;
    pNormalTimeDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    pNormalTimeDesc->ButtonBar.ButtonR.Valid = TRUE;
    pNormalTimeDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    pNormalTimeDesc->KeyFunc = Display_Setting_Delay_Setting_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_Time_Create;
    FuncList.OnCreate       = NULL;
    FuncList.OnSaveState    = Display_Setting_Delay_Setting_OnSaveState;
    FuncList.OnDestroy      = Display_Setting_Delay_Setting_Destroy;
    FuncList.OnRestoreState = Display_Setting_Delay_Setting_RestoreState;

    gp_SettingPhoneDisplayCurUIDesc = (VOID *)pNormalTimeDesc;
    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_DELAY_SETTING, &FuncList, pNormalTimeDesc);
} /* Display_Setting_Delay_Setting */

VOID Display_Setting_Auto_Keyguard_Setting_ON_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Delay_Setting();
    }
}

VOID Display_Setting_Auto_Keyguard_Setting_OFF_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingKeyguardSettingsCurUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_OFF;

        Setting_Set_Auto_Guard_On(FALSE);
        Setting_Set_Auto_Guard_Delay(0);
        Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_KEYGUARD_SETTINGS);
        // Nav_Back(ACT_ID_ANY);
    }
}

VOID Display_Setting_Keyguard_Settings_Auto_Keyguard_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UINT8 CurSetting = 0;

        if (TRUE == g_SettingPhoneSettingMng.AutoGuardOn)
        {
            CurSetting = 1;
        }

        Display_Setting_On_Off(ACT_ID_SETTING_KEYGUARD_SETTINGS,PHONE_TEXT_ID_AUTO_KEYGUARD,CurSetting,Display_Setting_Auto_Keyguard_Setting_ON_Cb,Display_Setting_Auto_Keyguard_Setting_OFF_Cb);
    }
}

VOID Display_Setting_Keyguard_Code_ON_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingKeyguardSettingsCurUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_ON;

        Setting_Set_Keyguard_On(TRUE);
        Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_ON, ACT_ID_SETTING_KEYGUARD_SETTINGS);
    }
}

VOID Display_Setting_Keyguard_Code_OFF_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingKeyguardSettingsCurUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_OFF;

        Setting_Set_Keyguard_On(FALSE);
        Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_OFF, ACT_ID_SETTING_KEYGUARD_SETTINGS);
    }
}

/**
 * display Setting_On_Off_Keyguard_Code
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Keyguard_Code(VOID)
{
    UINT8 CurSetting = 0;

    if (TRUE == g_SettingPhoneSettingMng.KeyguardOn)
    {
        CurSetting = 1;
    }

    Display_Setting_On_Off(ACT_ID_SETTING_ENTER_SECURITY_CODE,PHONE_TEXT_ID_KEYGUARD_CODE,CurSetting,Display_Setting_Keyguard_Code_ON_Cb,Display_Setting_Keyguard_Code_OFF_Cb);
}

/**
 *
 * Callback of Setting_Keygurad_Security_Code, on create
 * param (in) pPara: VOID *
 * return void:
 */
VOID Display_Setting_Keygurad_Security_Code_Create(VOID *pPara)
{
    INT8                              Text[2]                 = { 0, 0 };
    UI_Normal_NoTitle_Label_Ta_Desc_t *NormalNoTitleLblTaDesc = NULL;

    NormalNoTitleLblTaDesc = (UI_Normal_NoTitle_Label_Ta_Desc_t *)pPara;

    Text[0] = NV_SETTING_SECURITY_CODE_LEN + 0x30;
    lv_label_set_text(NormalNoTitleLblTaDesc->ContLabelTr.Label, Text);

    // set max length of TA
    lv_textarea_set_max_length(NormalNoTitleLblTaDesc->ContTa.TextArea, NV_SETTING_SECURITY_CODE_LEN);
    lv_textarea_set_pwd_mode(NormalNoTitleLblTaDesc->ContTa.TextArea, TRUE);
    Ime_Set_Mode(LV_IME_MODE_NUM);
    Ime_Set_SingleMode(TRUE);
}

/**
 *
 * Callback of Display_Setting_Keygurad_Security_Code, on destroy
 * param (in) pPara: VOID*
 * return void:
 */
VOID Display_Setting_Keygurad_Security_Code_Destroy(VOID *pPara)
{
    UI_Normal_NoTitle_Label_Ta_Desc_t *NormalNoTitleLblTaDesc = NULL;

    NormalNoTitleLblTaDesc = (UI_Normal_NoTitle_Label_Ta_Desc_t *)pPara;

    Hal_Mem_Free(NormalNoTitleLblTaDesc->ContTa.TaTxt);
    Hal_Mem_Free(NormalNoTitleLblTaDesc);
}

/**
 *
 * Callback of Display_Setting_Keygurad_Security_Code, on savestate
 * param (in) pPara: VOID*
 * return void:
 */
VOID Display_Setting_Keygurad_Security_Code_SaveState(VOID *pPara)
{
    UI_Normal_NoTitle_Label_Ta_Desc_t *NormalNoTitleLblTaDesc = NULL;
    INT8                              *Text                   = NULL;
    UINT8                             Len;

    NormalNoTitleLblTaDesc = (UI_Normal_NoTitle_Label_Ta_Desc_t *)pPara;
    Text                   = (INT8 *)lv_textarea_get_text(NormalNoTitleLblTaDesc->ContTa.TextArea);
    Len                    = strlen(Text);

    if (0 != Len)
    {
        Hal_Mem_Set(NormalNoTitleLblTaDesc->ContTa.TaTxt, 0, NV_SETTING_SECURITY_CODE_LEN + 1);
        Hal_Mem_Copy(NormalNoTitleLblTaDesc->ContTa.TaTxt, Text, Len);
    }
}

/**
 *
 * Callback of Display_Setting_Keygurad_Security_Code, on restroestate
 * param (in) pPara: VOID*
 * return void:
 */
VOID Display_Setting_Keygurad_Security_Code_RestroeState(VOID *pPara)
{
    UI_Normal_NoTitle_Label_Ta_Desc_t *NormalNoTitleLblTaDesc = NULL;
    lv_obj_t                          *Label                  = NULL;
    lv_obj_t                          *Ta                     = NULL;
    UINT32                            Max;
    UINT8                             Digit;
    INT8                              Text[2] = { 0 };

    NormalNoTitleLblTaDesc = (UI_Normal_NoTitle_Label_Ta_Desc_t *)pPara;
    Label                  = NormalNoTitleLblTaDesc->ContLabelTr.Label;
    Ta                     = NormalNoTitleLblTaDesc->ContTa.TextArea;
    Digit                  = strlen(NormalNoTitleLblTaDesc->ContTa.TaTxt);
    Max                    = NV_SETTING_SECURITY_CODE_LEN;

    if (Max < Digit)
    {
        /* error */
        return;
    }

    Digit = Max - Digit;
    sprintf(Text, "%d", Digit);
    lv_label_set_text(Label, Text);
    lv_textarea_set_max_length(Ta, Max);
    lv_textarea_set_pwd_mode(Ta, TRUE);
    Ime_Set_Mode(LV_IME_MODE_NUM);
    Ime_Set_SingleMode(TRUE);
}

/**
 *
 * Display_Setting_Security_Settings
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Keygurad_Security_Code_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_NoTitle_Label_Ta_Desc_t *NormalNoTitleLblTaDesc;
    lv_obj_t                          *Ta           = NULL;
    lv_obj_t                          *Label        = NULL;
    UINT8                             *SecurityCode = NULL;
    INT8                              *Text         = NULL;
    UINT8                             Len1;
    UINT8                             Len2;
    UINT8                             Max;
    UINT8                             Ret       = 1;
    INT8                              Number[2] = { 0 };
    INT8                              Char      = 0;

    if (KEY_RELEASED != key_sta)
    {
        return(Ret);
    }

    NormalNoTitleLblTaDesc = (UI_Normal_NoTitle_Label_Ta_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;
    Ta                     = NormalNoTitleLblTaDesc->ContTa.TextArea;
    Text                   = (INT8 *)lv_textarea_get_text(Ta);
    Max                    = NV_SETTING_SECURITY_CODE_LEN;

    switch (key_val)
    {
    case KEY_SOFTLEFT: // back button, return to previous UI
        Nav_Back(ACT_ID_ANY);
        break;

    case KEY_SOFTRIGHT:// clear button
        if (NULL != Text)
        {
            Len1 = strlen(Text);

            lv_textarea_del_char(Ta);

            Text = (INT8 *)lv_textarea_get_text(Ta);
            Len2 = strlen(Text);
            if (Len1 != Len2) // number of characters in TA changed
            {
                Len2 = Max - Len2;
                sprintf(Number, "%d", Len2);
                Label = NormalNoTitleLblTaDesc->ContLabelTr.Label;
                lv_label_set_text(Label, Number);
            }
        }
        else
        {
            Ret = 0;
        }
        break;

    case KEY_OK:
        SecurityCode = (UINT8 *)lv_textarea_get_text(NormalNoTitleLblTaDesc->ContTa.TextArea);
        if (  (g_SettingSecuritySettingMng.SecurityCode[0] == SecurityCode[0])
           && (g_SettingSecuritySettingMng.SecurityCode[1] == SecurityCode[1])
           && (g_SettingSecuritySettingMng.SecurityCode[2] == SecurityCode[2])
           && (g_SettingSecuritySettingMng.SecurityCode[3] == SecurityCode[3]))
        {
            Display_Setting_Keyguard_Code();
        }
        else
        {
            lv_textarea_set_text(Ta, "");
            Display_Setting_Error(ACT_ID_SETTING_ENTER_SECURITY_CODE, PHONE_TEXT_ID_CODE_ERROR,ACT_ID_SETTING_ENTER_SECURITY_CODE, TRUE);
        }
        break;

    case KEY_0:
        Char = '0';
        break;

    case KEY_1:
        Char = '1';
        break;

    case KEY_2:
        Char = '2';
        break;

    case KEY_3:
        Char = '3';
        break;

    case KEY_4:
        Char = '4';
        break;

    case KEY_5:
        Char = '5';
        break;

    case KEY_6:
        Char = '6';
        break;

    case KEY_7:
        Char = '7';
        break;

    case KEY_8:
        Char = '8';
        break;

    case KEY_9:
        Char = '9';
        break;

    case KEY_ASTERISK:
        Char = '*';
        break;

    case KEY_HASH:
        Char = '#';
        break;

    case KEY_END:
        Nav_Home(ACT_ID_ANY);
        break;

    default:
        Ret = 0;
        break;
    } /* switch */

    if (0 != Char)
    {
        Len1 = strlen(Text);
        if (Len1 < Max)
        {
            lv_textarea_add_char(Ta, Char);

            if (NULL == Text) // empy in TA before character input
            {
                Ret = 0;
            }
            else
            {
                Text = (INT8 *)lv_textarea_get_text(Ta);
                Len1 = Max - strlen(Text);
                sprintf(Number, "%d", Len1);
                Label = NormalNoTitleLblTaDesc->ContLabelTr.Label;
                lv_label_set_text(Label, Number);
                // Hal_Mem_Set(NormalNoTitleLblTaDesc->ContTa.TaTxt, 0, NV_SETTING_SECURITY_CODE_LEN);
                // Hal_Mem_Copy(NormalNoTitleLblTaDesc->ContTa.TaTxt, Text, strlen(Text));
            }
        }
    }

    return(Ret);
} /* Display_Setting_Keygurad_Security_Code_KeyCb */

/**
 * display Setting_Security_Settings
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Keyguard_Security_Code(VOID)
{
    UI_Normal_NoTitle_Label_Ta_Desc_t *NormalNoTitleLblTaDesc;
    Nav_Func_List_t                   FuncList;

    NormalNoTitleLblTaDesc = (UI_Normal_NoTitle_Label_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));
    Hal_Mem_Set(NormalNoTitleLblTaDesc, 0, sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));

    NormalNoTitleLblTaDesc->ContLabelTl.TxtId       = LV_LANG_TXT_ID_NONE;
    NormalNoTitleLblTaDesc->ContLabelTl.SymbolId    = LV_SYMBOL_EDIT;
    NormalNoTitleLblTaDesc->ContLabelTl.SymbolAlign = LV_LABEL_ALIGN_LEFT;
    NormalNoTitleLblTaDesc->ContLabelTl.LabelAlign  = LV_ALIGN_IN_TOP_LEFT;

    NormalNoTitleLblTaDesc->ContLabelTr.TxtId      = LV_LANG_TXT_ID_NONE;
    NormalNoTitleLblTaDesc->ContLabelTr.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    NormalNoTitleLblTaDesc->ContLabelTr.LabelAlign = LV_ALIGN_IN_TOP_RIGHT;

    NormalNoTitleLblTaDesc->ContLabel.TxtId        = PHONE_TEXT_ID_SECURITY_CODE;
    NormalNoTitleLblTaDesc->ContLabel.TxtAlign     = LV_LABEL_ALIGN_CENTER;
    NormalNoTitleLblTaDesc->ContLabelTr.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;

    NormalNoTitleLblTaDesc->ContTa.TaTxt = (INT8 *)Hal_Mem_Alloc(NV_SETTING_SECURITY_CODE_LEN + 1);
    Hal_Mem_Set(NormalNoTitleLblTaDesc->ContTa.TaTxt, 0, NV_SETTING_SECURITY_CODE_LEN + 1);

    NormalNoTitleLblTaDesc->ContTa.TaCursorHide = FALSE;
    NormalNoTitleLblTaDesc->ContTa.TaAlign      = LV_ALIGN_IN_TOP_LEFT;

    NormalNoTitleLblTaDesc->ButtonCont.ButtonL.Valid = TRUE;
    NormalNoTitleLblTaDesc->ButtonCont.ButtonL.TxtId = PHONE_TEXT_ID_BACK;

    NormalNoTitleLblTaDesc->ButtonCont.ButtonM.Valid = TRUE;
    NormalNoTitleLblTaDesc->ButtonCont.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    NormalNoTitleLblTaDesc->ButtonCont.ButtonR.Valid = TRUE;
    NormalNoTitleLblTaDesc->ButtonCont.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;

    NormalNoTitleLblTaDesc->KeyFunc = Display_Setting_Keygurad_Security_Code_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_NoTitle_Label_Ta_Create;
    FuncList.OnCreate       = Display_Setting_Keygurad_Security_Code_Create;
    FuncList.OnDestroy      = Display_Setting_Keygurad_Security_Code_Destroy;
    FuncList.OnSaveState    = Display_Setting_Keygurad_Security_Code_SaveState;
    FuncList.OnRestoreState = Display_Setting_Keygurad_Security_Code_RestroeState;

    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalNoTitleLblTaDesc;
    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_ENTER_SECURITY_CODE, &FuncList, (VOID *)NormalNoTitleLblTaDesc);
} /* Display_Setting_Keyguard_Security_Code */

/**
 *
 * Callback of Display_Setting_Keyguard_Settings, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Keyguard_Settings_Destroy(VOID *pPara)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)pPara;

    Hal_Mem_Free(NormalContainerListDesc->ContList.ContainerList);
    Hal_Mem_Free(NormalContainerListDesc);
}

/**
 *
 * Display_Setting_Keyguard_Settings
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Keyguard_Settings_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingKeyguardSettingsCurUIDesc;

    if (KEY_DOWN == key_val)
    {
        NormalContainerListDesc->ContList.Index++;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_UP == key_val)
    {
        NormalContainerListDesc->ContList.Index += NormalContainerListDesc->ContList.ListContainerCnt;
        NormalContainerListDesc->ContList.Index--;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

VOID Display_Setting_Keyguard_Settings_Keyguard_Code_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Keyguard_Security_Code();
    }
}

/**
 * display Setting_Keyguard_Settings
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Keyguard_Settings(VOID)
{
    UINT8                           ListContainerCnt         = 0;
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;
    UI_Container_Base_Desc_t        *ContainerList           = NULL;
    Nav_Func_List_t                 FuncList;

    ListContainerCnt = 2;
    ContainerList    = (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(ListContainerCnt * sizeof(UI_Container_Base_Desc_t));
    Hal_Mem_Set(ContainerList, 0, ListContainerCnt * sizeof(UI_Container_Base_Desc_t));

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(NormalContainerListDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    NormalContainerListDesc->TitleBar.TxtId      = PHONE_TEXT_ID_KEYGUARD_SETTINGS;
    NormalContainerListDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    NormalContainerListDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    ContainerList[0].Label.TxtId      = PHONE_TEXT_ID_AUTO_KEYGUARD;
    ContainerList[0].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[0].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[0].Valid            = TRUE;
    ContainerList[0].Choise           = UI_BASE_OBJ_LABEL;
    if (TRUE == g_SettingPhoneSettingMng.AutoGuardOn)
    {
        ContainerList[0].u.Label2.TxtId = PHONE_TEXT_ID_ON;
    }
    else
    {
        ContainerList[0].u.Label2.TxtId = PHONE_TEXT_ID_OFF;
    }
    ContainerList[0].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[0].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;

    ContainerList[0].ReleaseFunc = Display_Setting_Keyguard_Settings_Auto_Keyguard_Cb;

    ContainerList[1].Label.TxtId      = PHONE_TEXT_ID_KEYGUARD_CODE;
    ContainerList[1].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[1].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[1].Valid            = TRUE;
    ContainerList[1].Choise           = UI_BASE_OBJ_LABEL;
    if (TRUE == g_SettingPhoneSettingMng.KeyguardOn)
    {
        ContainerList[1].u.Label2.TxtId = PHONE_TEXT_ID_ON;
    }
    else
    {
        ContainerList[1].u.Label2.TxtId = PHONE_TEXT_ID_OFF;
    }
    ContainerList[1].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[1].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    ContainerList[1].ReleaseFunc         = Display_Setting_Keyguard_Settings_Keyguard_Code_Cb;

    NormalContainerListDesc->ContList.ListContainerCnt = ListContainerCnt;
    NormalContainerListDesc->ContList.Index            = 0;
    NormalContainerListDesc->ContList.ContainerList    = ContainerList;

    NormalContainerListDesc->ButtonBar.ButtonL.Valid = FALSE;

    NormalContainerListDesc->ButtonBar.ButtonM.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;

    NormalContainerListDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalContainerListDesc->KeyFunc = Display_Setting_Keyguard_Settings_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_Container_List_Create;
    FuncList.OnDestroy = Display_Setting_Keyguard_Settings_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_KEYGUARD_SETTINGS, &FuncList, (VOID *)NormalContainerListDesc);
    gp_SettingKeyguardSettingsCurUIDesc = (VOID *)NormalContainerListDesc;
} /* Display_Setting_Keyguard_Settings */

VOID Display_Setting_Keyguard_Settings_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Keyguard_Settings();
    }
}

/**
 *
 * Callback of Display_Setting_Network_Searching, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Network_Searching_Destroy(VOID *NormalNoTitleLblTaDesc)
{
    Hal_Mem_Free(NormalNoTitleLblTaDesc);
}

/**
 *
 * Callback of Display_Setting_Network_Searching, KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Network_Searching_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_SOFTRIGHT == key_val)
    {
        MMI_Modem_Plmn_Search_Stop_Req();

        g_SettingPhoneSettingMng.PlmnSearchStat = SETTING_PLMN_SEARCH_NONE;

        Nav_Back(ACT_ID_SETTING_NETWORK_SEARCHING);

        return(1);
    }
    else if (KEY_END == key_val)
    {
        MMI_Modem_Plmn_Search_Stop_Req();
        g_SettingPhoneSettingMng.PlmnSearchStat = SETTING_PLMN_SEARCH_NONE;
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Network_Searching
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Network_Searching(VOID)
{
    UI_Normal_NoTitle_Desc_t *NormalNoTitleDesc;
    Nav_Func_List_t          FuncList;

    NormalNoTitleDesc = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(NormalNoTitleDesc, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    NormalNoTitleDesc->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_SEARCHING;
    NormalNoTitleDesc->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    NormalNoTitleDesc->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    NormalNoTitleDesc->ContenCont.ContImg.Img      = IMG_PROGRESS_BAR;
    NormalNoTitleDesc->ContenCont.ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;

    NormalNoTitleDesc->ButtonBar.ButtonL.Valid = FALSE;
    NormalNoTitleDesc->ButtonBar.ButtonM.Valid = FALSE;
    NormalNoTitleDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalNoTitleDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_QUIT;

    NormalNoTitleDesc->KeyFunc = Display_Setting_Network_Searching_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_NoTitle_Create;
    FuncList.OnDestroy = Display_Setting_Network_Searching_Destroy;

    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalNoTitleDesc;
    Nav_Forward(ACT_ID_SETTING_NETWORK_SELECTION, ACT_ID_SETTING_NETWORK_SEARCHING, &FuncList,(VOID *)NormalNoTitleDesc);
}

/**
 *
 * Callback of Display_Setting_Network_Selection, on restore
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Network_Selection_Restore(VOID *pPara)
{
    gp_SettingPhoneDisplayCurUIDesc = pPara;
}

/**
 *
 * Callback of Display_Setting_Network_Selection, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Network_Selection_Destroy(VOID *pPara)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc = NULL;

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)pPara;

    Hal_Mem_Free(NormalLstOnlyDesc->List.ButtonList);
    Hal_Mem_Free(NormalLstOnlyDesc);
}

VOID Display_Setting_Network_Selection_Auto_SIM1_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        MMI_Modem_Plmn_Search_Req_t *PlmnSearchReq = NULL;

        PlmnSearchReq = (MMI_Modem_Plmn_Search_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Plmn_Search_Req_t));
        Hal_Mem_Set(PlmnSearchReq, 0, sizeof(MMI_Modem_Plmn_Search_Req_t));

        PlmnSearchReq->simId      = MMI_MODEM_SIM_1;
        PlmnSearchReq->SearchType = MMI_MODEM_PLMN_SEARCH_AUTO;
        MMI_Modem_Plmn_Search_Req(PlmnSearchReq);

        // change global variable, nv write, Inform modem adapter
        Setting_Set_Plmn_Search_Mode(MMI_MODEM_SIM_1, SETTING_PLMN_SEARCH_AUTO);

        Display_Setting_SIM_Selection_Set(PHONE_TEXT_ID_AUTO, LV_LANG_TXT_ID_NONE, NULL, NULL);

        Display_Setting_Done(ACT_ID_SETTING_NETWORK_SELECTION, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_SIM_SELECTION);
    }
}

VOID Display_Setting_Network_Selection_Manual_SIM1_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        MMI_Modem_Plmn_Search_Req_t *PlmnSearchReq;

        PlmnSearchReq = (MMI_Modem_Plmn_Search_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Plmn_Search_Req_t));
        Hal_Mem_Set(PlmnSearchReq, 0, sizeof(MMI_Modem_Plmn_Search_Req_t));

        PlmnSearchReq->simId      = MMI_MODEM_SIM_1;
        PlmnSearchReq->SearchType = MMI_MODEM_PLMN_SEARCH_LIST;
        MMI_Modem_Plmn_Search_Req(PlmnSearchReq);

        g_SettingPhoneSettingMng.PlmnSearchStat = SETTING_PLMN_SEARCH_SIM1;

        Display_Setting_Network_Searching();
    }
}

VOID Display_Setting_Network_Selection_Auto_SIM2_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        MMI_Modem_Plmn_Search_Req_t *PlmnSearchReq = NULL;

        PlmnSearchReq = (MMI_Modem_Plmn_Search_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Plmn_Search_Req_t));
        Hal_Mem_Set(PlmnSearchReq, 0, sizeof(MMI_Modem_Plmn_Search_Req_t));

        PlmnSearchReq->simId      = MMI_MODEM_SIM_2;
        PlmnSearchReq->SearchType = MMI_MODEM_PLMN_SEARCH_AUTO;
        MMI_Modem_Plmn_Search_Req(PlmnSearchReq);

        // change global variable, nv write, Inform modem adapter
        Setting_Set_Plmn_Search_Mode(MMI_MODEM_SIM_2, SETTING_PLMN_SEARCH_AUTO);

        Display_Setting_SIM_Selection_Set(LV_LANG_TXT_ID_NONE, PHONE_TEXT_ID_AUTO, NULL, NULL);

        Display_Setting_Done(ACT_ID_SETTING_NETWORK_SELECTION, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_SIM_SELECTION);
    }
}

VOID Display_Setting_Network_Selection_Manual_SIM2_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        MMI_Modem_Plmn_Search_Req_t *PlmnSearchReq;

        PlmnSearchReq = (MMI_Modem_Plmn_Search_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Plmn_Search_Req_t));
        Hal_Mem_Set(PlmnSearchReq, 0, sizeof(MMI_Modem_Plmn_Search_Req_t));

        PlmnSearchReq->simId      = MMI_MODEM_SIM_2;
        PlmnSearchReq->SearchType = MMI_MODEM_PLMN_SEARCH_LIST;
        MMI_Modem_Plmn_Search_Req(PlmnSearchReq);

        g_SettingPhoneSettingMng.PlmnSearchStat = SETTING_PLMN_SEARCH_SIM2;

        Display_Setting_Network_Searching();
    }
}

/**
 * Key Callback Function of Setting_Network_Selection
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Network_Selection_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8                      Ret                 = 0;
    UINT8                      Index               = 0;
    UI_Normal_List_Only_Desc_t *NormalListOnlyDesc = NULL;

    if (KEY_RELEASED != key_sta)
    {
        return(Ret);
    }

    NormalListOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;
    Index              = NormalListOnlyDesc->List.Index;

    if (KEY_DOWN == key_val)
    {
        Index++;
        Index                         %= NormalListOnlyDesc->List.ListButtonCnt;
        NormalListOnlyDesc->List.Index = Index;
    }
    else if (KEY_UP == key_val)
    {
        Index += NormalListOnlyDesc->List.ListButtonCnt;
        Index--;
        Index                         %= NormalListOnlyDesc->List.ListButtonCnt;
        NormalListOnlyDesc->List.Index = Index;
    }
    else if (KEY_SOFTRIGHT == key_val)
    {   // return to previous UI
        Nav_Back(ACT_ID_ANY);
        Ret = 1;
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        Ret = 1;
    }

    return(Ret);
}

/**
 * display Setting_Network_Selection
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Network_Selection(MMI_MODEM_SIM_ID SimId)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;
    lv_event_cb_t              ReleaseFun1;
    lv_event_cb_t              ReleaseFun2;

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_NETWORK_SEL;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    if (MMI_MODEM_SIM_1 == SimId)
    {
        ReleaseFun1 = Display_Setting_Network_Selection_Auto_SIM1_Cb;
        ReleaseFun2 = Display_Setting_Network_Selection_Manual_SIM1_Cb;

        if (SETTING_PLMN_SEARCH_AUTO == g_SettingPhoneSettingMng.PlmnSearchMode[0])
        {
            NormalLstOnlyDesc->List.Index = 0;
        }
        else
        {
            NormalLstOnlyDesc->List.Index = 1;
        }
    }
    else
    {
        ReleaseFun1 = Display_Setting_Network_Selection_Auto_SIM2_Cb;
        ReleaseFun2 = Display_Setting_Network_Selection_Manual_SIM2_Cb;

        if (SETTING_PLMN_SEARCH_AUTO == g_SettingPhoneSettingMng.PlmnSearchMode[1])
        {
            NormalLstOnlyDesc->List.Index = 0;
        }
        else
        {
            NormalLstOnlyDesc->List.Index = 1;
        }
    }

    NormalLstOnlyDesc->List.ListButtonCnt = 2;
    NormalLstOnlyDesc->List.ButtonList    = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);

    NormalLstOnlyDesc->List.ButtonList[0].ButtonIndex = 0;
    NormalLstOnlyDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_AUTO;
    NormalLstOnlyDesc->List.ButtonList[0].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[0].ReleaseFun  = ReleaseFun1;
    NormalLstOnlyDesc->List.ButtonList[1].ButtonIndex = 1;
    NormalLstOnlyDesc->List.ButtonList[1].TxtId       = PHONE_TEXT_ID_MANUAL;
    NormalLstOnlyDesc->List.ButtonList[1].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[1].ReleaseFun  = ReleaseFun2;

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;
    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Display_Setting_Network_Selection_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_List_Only_Create;
    FuncList.OnRestoreState    = Display_Setting_Network_Selection_Restore;
    FuncList.OnDestroy = Display_Setting_Network_Selection_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_NETWORK_SELECTION, &FuncList, (VOID *)NormalLstOnlyDesc);
    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalLstOnlyDesc;
}     /* Display_Setting_Network_Selection */

VOID Display_Setting_Sim_Selection_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_PHONE_TEXT_ID Sim1ValueTxtId = LV_LANG_TXT_ID_NONE;
        UI_PHONE_TEXT_ID Sim2ValueTxtId = LV_LANG_TXT_ID_NONE;

        if (SETTING_PLMN_SEARCH_AUTO == g_SettingPhoneSettingMng.PlmnSearchMode[0])
        {
            Sim1ValueTxtId = PHONE_TEXT_ID_AUTO;
        }
        else
        {
            Sim1ValueTxtId = PHONE_TEXT_ID_MANUAL;
        }

        if (SETTING_PLMN_SEARCH_AUTO == g_SettingPhoneSettingMng.PlmnSearchMode[1])
        {
            Sim2ValueTxtId = PHONE_TEXT_ID_AUTO;
        }
        else
        {
            Sim2ValueTxtId = PHONE_TEXT_ID_MANUAL;
        }

        Display_Setting_SIM_Selection(ACT_ID_SETTING_PHONE_SETTINGS,Sim1ValueTxtId, Sim2ValueTxtId, NULL, NULL,Display_Setting_Network_Selection);
    }
}

/**
 *
 * Callback of Display_Setting_Network_Requesting, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Network_Requesting_Destroy(VOID *NormalNoTitleLblTaDesc)
{
    Hal_Mem_Free(NormalNoTitleLblTaDesc);
}

/**
 *
 * Callback of Display_Setting_Network_Requesting, KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Network_Requesting_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_SOFTRIGHT == key_val)
    {
        MMI_Modem_Plmn_Search_Stop_Req();
        Nav_Back(ACT_ID_SETTING_NETWORK_REQUESTING);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        MMI_Modem_Plmn_Search_Stop_Req();
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Network_Requesting
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Network_Requesting(VOID)
{
    UI_Normal_NoTitle_Desc_t *NormalNoTitleDesc;
    Nav_Func_List_t          FuncList;

    NormalNoTitleDesc = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(NormalNoTitleDesc, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    NormalNoTitleDesc->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_REQUESTING;
    NormalNoTitleDesc->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    NormalNoTitleDesc->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    NormalNoTitleDesc->ContenCont.ContImg.Img      = IMG_PROGRESS_BAR;
    NormalNoTitleDesc->ContenCont.ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;

    NormalNoTitleDesc->ButtonBar.ButtonL.Valid = FALSE;
    NormalNoTitleDesc->ButtonBar.ButtonM.Valid = FALSE;
    NormalNoTitleDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalNoTitleDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_QUIT;

    NormalNoTitleDesc->KeyFunc = Display_Setting_Network_Requesting_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_NoTitle_Create;
    FuncList.OnDestroy = Display_Setting_Network_Requesting_Destroy;

    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalNoTitleDesc;
    Nav_Forward(ACT_ID_SETTING_OPERATORS_LIST, ACT_ID_SETTING_NETWORK_REQUESTING, &FuncList, (VOID *)NormalNoTitleDesc);
}

VOID Display_Setting_Operators_List_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        MMI_Modem_Plmn_Search_Req_t *PlmnSearchReq;
        UI_Normal_List_Only_Desc_t  *NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;

        PlmnSearchReq = (MMI_Modem_Plmn_Search_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Plmn_Search_Req_t));
        Hal_Mem_Set(PlmnSearchReq, 0, sizeof(MMI_Modem_Plmn_Search_Req_t));

        // Inform modem adapter
        if (SETTING_PLMN_SEARCH_SIM1 == g_SettingPhoneSettingMng.PlmnSearchStat)
        {   // SETTING_PLMN_SEARCH_SIM1
            PlmnSearchReq->simId = MMI_MODEM_SIM_1;
        }
        else
        {   // SETTING_PLMN_SEARCH_SIM2
            PlmnSearchReq->simId = MMI_MODEM_SIM_2;
        }

        PlmnSearchReq->SearchType = MMI_MODEM_PLMN_SEARCH_SPEC;
        Hal_Mem_Copy(&(PlmnSearchReq->SpecPlmn), &SettingPhonePlmnList[NormalLstOnlyDesc->List.Index],sizeof(MMI_Modem_PLMN_Info));
        MMI_Modem_Plmn_Search_Req(PlmnSearchReq);

        Display_Setting_Network_Requesting();
    }
}

/**
 *
 * Callback of Display_Setting_Operators_List, on restore
 * param (in) NormalListOnlyDesc: UI_Normal_List_Only_Desc_t*
 * return void:
 */
VOID Display_Setting_Operators_List_Restore(VOID *pPara)
{
    gp_SettingPhoneDisplayCurUIDesc = pPara;
}

/**
 * Display Setting_Operators_List, OnDestroy Function, free pointer
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Operators_List_Destroy(VOID *pPara)
{
    UI_Normal_List_Only_Desc_t *NormalListOnlyDesc = NULL;
    UINT8                      i                   = 0;

    NormalListOnlyDesc = (UI_Normal_List_Only_Desc_t *)pPara;

    for (i = 0; i < NormalListOnlyDesc->List.ListButtonCnt; i++)
    {
        Hal_Mem_Free(NormalListOnlyDesc->List.ButtonList[i].BtnTxt);
    }

    Hal_Mem_Free(NormalListOnlyDesc->List.ButtonList);
    Hal_Mem_Free(NormalListOnlyDesc);
}

/**
 *
 * Display_Setting_Operators_List
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Operators_List_Key_Cb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;

    if (KEY_DOWN == key_val)
    {
        NormalLstOnlyDesc->List.Index++;
        NormalLstOnlyDesc->List.Index %= NormalLstOnlyDesc->List.ListButtonCnt;
        return(0);
    }
    else if (KEY_UP == key_val)
    {
        NormalLstOnlyDesc->List.Index += NormalLstOnlyDesc->List.ListButtonCnt;
        NormalLstOnlyDesc->List.Index--;
        NormalLstOnlyDesc->List.Index %= NormalLstOnlyDesc->List.ListButtonCnt;
        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI, ACT_ID_SETTING_NETWORK_SELECTION
        if (NULL != SettingPhonePlmnList)
        {
            Hal_Mem_Free(SettingPhonePlmnList);
            SettingPhonePlmnList = NULL;
        }

        Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_NETWORK_SELECTION, NULL, NULL);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Operators_List
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Operators_List(MMI_Modem_Plmn_Search_Cnf_t *PlmnSearchCnf)
{
    UINT8                      i;
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_OPERATORS;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    NormalLstOnlyDesc->List.ListButtonCnt = PlmnSearchCnf->PlmnCnt;
    if (0 < PlmnSearchCnf->PlmnCnt)
    {
        NormalLstOnlyDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);
        Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);
    }

    for (i = 0; i < NormalLstOnlyDesc->List.ListButtonCnt; i++)
    {
        NormalLstOnlyDesc->List.ButtonList[i].ButtonIndex = i;
        NormalLstOnlyDesc->List.ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        NormalLstOnlyDesc->List.ButtonList[i].Valid       = TRUE;
        NormalLstOnlyDesc->List.ButtonList[i].ReleaseFun  = Display_Setting_Operators_List_Cb;
        NormalLstOnlyDesc->List.ButtonList[i].BtnTxt      = (INT8 *)Hal_Mem_Alloc(MMI_MAX_PLMN_NAME_LEN);
        Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList[i].BtnTxt, 0, MMI_MAX_PLMN_NAME_LEN);
        Hal_Mem_Copy(NormalLstOnlyDesc->List.ButtonList[i].BtnTxt, PlmnSearchCnf->PlmnList[i].PlmnName,MMI_MAX_PLMN_NAME_LEN);
    }

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;

    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;

    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Display_Setting_Operators_List_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_List_Only_Create;
    FuncList.OnRestoreState = Display_Setting_Operators_List_Restore;
    FuncList.OnDestroy      = Display_Setting_Operators_List_Destroy;

    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalLstOnlyDesc;
    Nav_Forward(ACT_ID_SETTING_NETWORK_SEARCHING, ACT_ID_SETTING_OPERATORS_LIST, &FuncList, (VOID *)NormalLstOnlyDesc);
}     /* Display_Setting_Operators_List */

/**
 *
 * Callback of Setting module, auto-back timer
 * param (in) Para: UINT32
 * return void:
 */
VOID Display_Setting_Done_Timeout(VOID* Para)
{
    Nav_Home(ACT_ID_SETTING_DONE);
}

/**
 *
 * Callback of Setting_Done, on create
 * param (in) pPara: VOID*
 * return void:
 */
VOID Display_Setting_Done_Select_Newtwork_Create(VOID *pPara)
{
    // Create & start 2s auto-back timer
    UINT8 Para = 0;
    g_SettingDoneTimer = Hal_Timer_Start(2000, Display_Setting_Done_Timeout, (VOID *)&Para, FALSE);
}

/**
 *
 * Callback of Settings_Done, on destroy
 * param (in) pPara: VOID*, pointer of UI_Status_Desc_t
 * return void:
 */
VOID Display_Setting_Done_Select_Newtwork_Destroy(VOID *pPara)
{
    Hal_Mem_Free(pPara);
}

/**
 *
 * Callback of Setting_Done, KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Done_Select_Newtwork_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Done
 * param (in) CallerActId   : ACTIVITY_ID, the activity Id from which entered setting done screen
 *       (in) TxtId         : UI_PHONE_TEXT_ID, the text shown on screen
 *       (in) AutoNextActId : ACTIVITY_ID, the next activity Id auto entered from setting_done
 * return void:
 */
VOID Display_Setting_Done_Select_Newtwork(INT8 *Text)
{
    UI_Status_Desc_t *StatusDesc = NULL;
    Nav_Func_List_t  FuncList;

    StatusDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(StatusDesc, 0, sizeof(UI_Status_Desc_t));

    StatusDesc->ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    StatusDesc->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    StatusDesc->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    StatusDesc->ContImg.Img          = LV_SYMBOL_OK;
    StatusDesc->ContImg.ImgAlign     = LV_ALIGN_IN_TOP_RIGHT;
    StatusDesc->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    StatusDesc->KeyFunc = Display_Setting_Done_Select_Newtwork_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Status_Create;
    FuncList.OnCreate  = Display_Setting_Done_Select_Newtwork_Create;
    FuncList.OnDestroy = Display_Setting_Done_Select_Newtwork_Destroy;

    Nav_Forward(ACT_ID_SETTING_NETWORK_REQUESTING, ACT_ID_SETTING_DONE, &FuncList, (VOID *)StatusDesc);

    lv_label_set_text(StatusDesc->ContLabel.Label, Text);
}

VOID Phone_Modem_Plmn_Search_Cnf(MMI_Modem_Plmn_Search_Cnf_t *PlmnSearchCnf)
{
    INT8                     *Text              = NULL;
    INT8                     *TempTxt1          = NULL;
    INT8                     *TempTxt2          = NULL;
    UI_Normal_NoTitle_Desc_t *NormalNoTitleDesc = NULL;
    INT8                     TextCmcc[]         = "CMCC";
    INT8                     TextCucc[]         = "UNICOM";
    INT8                     TextCtcc[]         = "CT";
    INT8                     S                  = ':';
    UINT8                    Len                = 0;
    UINT8                    Len1               = 0;
    UINT8                    Len2               = 0;
    UI_PHONE_TEXT_ID         TxtId              = LV_LANG_TXT_ID_NONE;

    printf("%s\n", __FUNCTION__);
    NormalNoTitleDesc = (UI_Normal_NoTitle_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;

    if (  (  (MMI_MODEM_SIM_1 == PlmnSearchCnf->simId)
          && (SETTING_PLMN_SEARCH_SIM1 == g_SettingPhoneSettingMng.PlmnSearchStat))
       || (  (MMI_MODEM_SIM_2 == PlmnSearchCnf->simId)
          && (SETTING_PLMN_SEARCH_SIM2 == g_SettingPhoneSettingMng.PlmnSearchStat)))
    {
        if (0 < PlmnSearchCnf->PlmnCnt)
        {     // succ
            if (PHONE_TEXT_ID_SEARCHING == NormalNoTitleDesc->ContenCont.ContLabel.TxtId)
            { // list searching
                if (NULL == SettingPhonePlmnList)
                {
                    SettingPhonePlmnList = (MMI_Modem_PLMN_Info *)Hal_Mem_Alloc(sizeof(MMI_Modem_PLMN_Info) * PlmnSearchCnf->PlmnCnt);
                    Hal_Mem_Set(SettingPhonePlmnList, 0,sizeof(MMI_Modem_PLMN_Info) * PlmnSearchCnf->PlmnCnt);
                }
                Hal_Mem_Copy(SettingPhonePlmnList, PlmnSearchCnf->PlmnList,sizeof(MMI_Modem_PLMN_Info) * PlmnSearchCnf->PlmnCnt);

                Display_Setting_Operators_List(PlmnSearchCnf);
            }
            else if (PHONE_TEXT_ID_REQUESTING == NormalNoTitleDesc->ContenCont.ContLabel.TxtId)
            {   // spec searching
                // change global variable, nv write, Inform modem adapter
                Setting_Set_Plmn_Search_Mode(PlmnSearchCnf->simId, SETTING_PLMN_SEARCH_MANUAL);
                g_SettingPhoneSettingMng.PlmnSearchStat = SETTING_PLMN_SEARCH_NONE;
                if (NULL != SettingPhonePlmnList)
                {
                    Hal_Mem_Free(SettingPhonePlmnList);
                    SettingPhonePlmnList = NULL;
                }
                printf("%s: plmnname = %s\n",__FUNCTION__, PlmnSearchCnf->PlmnList->PlmnName);
                if (0 == strcmp(PlmnSearchCnf->PlmnList->PlmnName, TextCmcc))
                {
                    TxtId = PHONE_TEXT_ID_CMCC;
                }
                else if (0 == strcmp(PlmnSearchCnf->PlmnList->PlmnName, TextCucc))
                {
                    TxtId = PHONE_TEXT_ID_CUCC;
                }
                else if (0 == strcmp(PlmnSearchCnf->PlmnList->PlmnName, TextCtcc))
                {
                    TxtId = PHONE_TEXT_ID_CTCC;
                }

                TempTxt1 = (INT8 *)lv_lang_get_text(PHONE_TEXT_ID_SELECT);
                Len1     = strlen(TempTxt1);

                if (LV_LANG_TXT_ID_NONE == TxtId)
                {
                    while (PlmnSearchCnf->PlmnList->PlmnName[Len2] != '\0')
                    {
                        Len2++;
                    }

                    TempTxt2 = (INT8 *)Hal_Mem_Alloc(Len2);
                    Hal_Mem_Set(TempTxt2, 0, Len2);
                    sprintf(TempTxt2, "%s", PlmnSearchCnf->PlmnList->PlmnName);
                }
                else
                {
                    TempTxt2 = (INT8 *)lv_lang_get_text(TxtId);
                    Len2     = strlen(TempTxt2);
                }

                Len  = Len1 + Len2 + 1;
                Text = (INT8 *)Hal_Mem_Alloc(Len);
                Hal_Mem_Set(Text, 0, Len);
                Hal_Mem_Copy(Text, TempTxt1, Len1);
                Hal_Mem_Copy((Text + Len1), &S, 1);
                Hal_Mem_Copy((Text + Len1 + 1), TempTxt2, Len2);

                Display_Setting_Done_Select_Newtwork(Text);

                if ((0 < Len2) && (LV_LANG_TXT_ID_NONE == TxtId))
                {
                    Hal_Mem_Free(TempTxt2);
                }

                if (NULL != Text)
                {
                    Hal_Mem_Free(Text);
                }
            }
        }
        else
        {     // fail, PlmnSearchCnf->PlmnCnt is 0
            if (PHONE_TEXT_ID_SEARCHING == NormalNoTitleDesc->ContenCont.ContLabel.TxtId)
            { // list searching fail
                Display_Setting_Error(ACT_ID_SETTING_NETWORK_SEARCHING, PHONE_TEXT_ID_SEARCH_FAILED,ACT_ID_SETTING_NETWORK_SELECTION, TRUE);
            }
            else if (PHONE_TEXT_ID_REQUESTING == NormalNoTitleDesc->ContenCont.ContLabel.TxtId)
            {   // spec searching fail
                // set auto searching
                MMI_Modem_Plmn_Search_Req_t *PlmnSearchReq = NULL;
                PlmnSearchReq = (MMI_Modem_Plmn_Search_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Plmn_Search_Req_t));
                Hal_Mem_Set(PlmnSearchReq, 0, sizeof(MMI_Modem_Plmn_Search_Req_t));
                PlmnSearchReq->simId      = PlmnSearchCnf->simId;
                PlmnSearchReq->SearchType = MMI_MODEM_PLMN_SEARCH_AUTO;
                MMI_Modem_Plmn_Search_Req(PlmnSearchReq);

                // change global variable, nv write, Inform modem adapter
                Setting_Set_Plmn_Search_Mode(PlmnSearchCnf->simId, SETTING_PLMN_SEARCH_AUTO);
                Display_Setting_Error(ACT_ID_SETTING_NETWORK_REQUESTING, PHONE_TEXT_ID_NO_NETWORK,ACT_ID_SETTING_OPERATORS_LIST, TRUE);
            }
        }
    }

    if (NULL != PlmnSearchCnf->PlmnList)
    {
        Hal_Mem_Free(PlmnSearchCnf->PlmnList);
    }
    if (NULL != PlmnSearchCnf)
    {
        Hal_Mem_Free(PlmnSearchCnf);
    }
} /* MMI_Modem_Plmn_Search_Cnf */

VOID Display_Setting_Startup_Tone_ON_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_ON;

        Setting_Set_Startup_Tone_On(TRUE);
        Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_PHONE_SETTINGS);
    }
}

VOID Display_Setting_Startup_Tone_OFF_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_OFF;

        Setting_Set_Startup_Tone_On(FALSE);
        Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_PHONE_SETTINGS);
    }
}

/**
 * display Setting_Startup_Tone
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Startup_Tone(VOID)
{
    UINT8 CurSetting = 0;

    if (TRUE == g_SettingPhoneSettingMng.StartupToneOn)
    {
        CurSetting = 1;
    }

    Display_Setting_On_Off(ACT_ID_SETTING_PHONE_SETTINGS,PHONE_TEXT_ID_STARTUP_TONE,CurSetting,Display_Setting_Startup_Tone_ON_Cb,Display_Setting_Startup_Tone_OFF_Cb);
}     /* Display_Setting_Startup_Tone */

VOID Display_Setting_Startup_Tone_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Startup_Tone();
    }
}

/**
 * Key Callback Function of Setting_Welcome_Note_Opt
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Welcome_Note_Opt_Key_Cb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8                      Ret                 = 0;
    UINT8                      Index               = 0;
    UI_Normal_List_Only_Desc_t *NormalListOnlyDesc = NULL;

    if (KEY_RELEASED != key_sta)
    {
        return(Ret);
    }

    NormalListOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;
    Index              = NormalListOnlyDesc->List.Index;

    if (KEY_DOWN == key_val)
    {
        Index++;
        Index                         %= NormalListOnlyDesc->List.ListButtonCnt;
        NormalListOnlyDesc->List.Index = Index;
    }
    else if (KEY_UP == key_val)
    {
        Index += NormalListOnlyDesc->List.ListButtonCnt;
        Index--;
        Index                         %= NormalListOnlyDesc->List.ListButtonCnt;
        NormalListOnlyDesc->List.Index = Index;
    }
    else if (KEY_SOFTRIGHT == key_val)
    {   // return to previous UI
        Nav_Back(ACT_ID_ANY);
        Ret = 1;
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        Ret = 1;
    }

    return(Ret);
}

/**
 * Display Setting_Welcome_Note_Opt, OnDestroy Function, free pointer
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Welcome_Note_Opt_Destroy(VOID *pPara)
{
    UI_Normal_List_Only_Desc_t *NormalListOnlyDesc = NULL;

    NormalListOnlyDesc = (UI_Normal_List_Only_Desc_t *)pPara;

    Hal_Mem_Free(NormalListOnlyDesc->List.ButtonList);
    Hal_Mem_Free(NormalListOnlyDesc);
}

VOID Display_Setting_Welcome_Note_Opt_Save_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_PHONE_TEXT_ID TxtId;

        // change global variable Note_On
        if (0 == g_SettingPhoneSettingMng.WelcomeNote[0])
        {       // no note
            Setting_Set_Welcome_Note_On(FALSE);
            TxtId = PHONE_TEXT_ID_WELCOME_NOTE_DELETED;
        }
        else
        {
            Setting_Set_Welcome_Note_On(TRUE);
            TxtId = PHONE_TEXT_ID_WELCOME_NOTE_SAVED;
        }

        // change global variable Note
        Setting_Set_Welcome_Note(g_SettingPhoneSettingMng.WelcomeNote);

        Display_Setting_Done(ACT_ID_SETTING_WELCOME_NOTE_OPT, TxtId, ACT_ID_SETTING_PHONE_SETTINGS);
    }
}

VOID Display_Setting_Welcome_Note_Opt_Delete_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        // change global variable Note_On
        Setting_Set_Welcome_Note_On(FALSE);

        // change global variable Note
        Hal_Mem_Set(g_SettingPhoneSettingMng.WelcomeNote, 0, SETTING_MAX_WELCOME_NOTE_STR_LEN);
        Setting_Set_Welcome_Note(g_SettingPhoneSettingMng.WelcomeNote);

        Display_Setting_Done(ACT_ID_SETTING_WELCOME_NOTE_OPT, PHONE_TEXT_ID_WELCOME_NOTE_DELETED,ACT_ID_SETTING_PHONE_SETTINGS);
    }
}

/**
 * display Setting_Welcome_Note_Opt
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Welcome_Note_Opt(VOID)
{
    UI_Normal_List_Only_Desc_t *NormalLstOnlyDesc;
    Nav_Func_List_t            FuncList;

    NormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(NormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    NormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_WELCOME_NOTE;
    NormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    NormalLstOnlyDesc->List.ListButtonCnt = 2;
    NormalLstOnlyDesc->List.ButtonList    = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);
    Hal_Mem_Set(NormalLstOnlyDesc->List.ButtonList, 0, sizeof(UI_Button_Desc_t) * NormalLstOnlyDesc->List.ListButtonCnt);

    NormalLstOnlyDesc->List.ButtonList[0].ButtonIndex = 0;
    NormalLstOnlyDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_SAVE;
    NormalLstOnlyDesc->List.ButtonList[0].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[0].ReleaseFun  = Display_Setting_Welcome_Note_Opt_Save_Cb;

    NormalLstOnlyDesc->List.ButtonList[1].ButtonIndex = 1;
    NormalLstOnlyDesc->List.ButtonList[1].TxtId       = PHONE_TEXT_ID_DELETE;
    NormalLstOnlyDesc->List.ButtonList[1].Valid       = TRUE;
    NormalLstOnlyDesc->List.ButtonList[1].ReleaseFun  = Display_Setting_Welcome_Note_Opt_Delete_Cb;

    NormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;

    NormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    NormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    NormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalLstOnlyDesc->KeyFunc = Display_Setting_Welcome_Note_Opt_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_List_Only_Create;
    FuncList.OnDestroy = Display_Setting_Welcome_Note_Opt_Destroy;

    Nav_Forward(ACT_ID_SETTING_WELCOME_NOTE, ACT_ID_SETTING_WELCOME_NOTE_OPT, &FuncList, (VOID *)NormalLstOnlyDesc);
}     /* Display_Setting_Welcome_Note_Opt */

lv_res_t Display_Setting_Welcome_Note_Opt_Cb(lv_obj_t *Btn)
{
    Display_Setting_Welcome_Note_Opt();

    return(LV_RES_OK);
}

UINT8 Display_Setting_Welcome_Note_Get_Max_Len(INT8 *Txt)
{
    UINT8  Len = strlen(Txt);
    UINT8  Num = 0;
    UINT32 i = 0;
    while (Len > i)
    {
        _lv_txt_encoded_next(Txt, &i);
        Num++;
    }
    UINT8 MaxLen = Len + (SETTING_MAX_WELCOME_NOTE_CHARS_NUM - Num) * 3;
    return MaxLen;
}

VOID Display_Setting_Welcome_Note_Input_Char(UINT8 Len)
{
    lv_obj_t                    *label               = NULL;
    UI_Normal_NoTitle_Ta_Desc_t *NormalNoTitleTaDesc = NULL;
    const INT8 *                Txt;

    NormalNoTitleTaDesc = (UI_Normal_NoTitle_Ta_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;
    label               = lv_obj_get_child(NormalNoTitleTaDesc->ButtonBar.ButtonR.Button, NULL);

    Txt = lv_textarea_get_text(NormalNoTitleTaDesc->ContTa.TextArea);
    lv_textarea_set_max_length(NormalNoTitleTaDesc->ContTa.TextArea,
                               Display_Setting_Welcome_Note_Get_Max_Len((INT8 *)Txt));
    if (PHONE_TEXT_ID_BACK == lv_label_get_text_id(label))
    {       // old TxtId is BACK */
        lv_label_set_text_id(label,PHONE_TEXT_ID_CLEAR);
    }
}

/**
 *
 * Callback of Display_Setting_Welcome_Note, on create state
 * param (in) NormalTaOnlyDesc: UI_Normal_Ta_Only_Desc_t*
 * return void:
 */
VOID Display_Setting_Welcome_Note_CreateState(VOID *pPara)
{
    UI_Normal_NoTitle_Ta_Desc_t *NormalNoTitleTaDesc = NULL;

    NormalNoTitleTaDesc = (UI_Normal_NoTitle_Ta_Desc_t *)pPara;
    lv_textarea_set_max_length(NormalNoTitleTaDesc->ContTa.TextArea,
                               Display_Setting_Welcome_Note_Get_Max_Len(
                                   NormalNoTitleTaDesc->ContTa.TaTxt));
}

/**
 *
 * Callback of Display_Setting_Welcome_Note, on destroy
 * param (in) NormalTaOnlyDesc: UI_Normal_Ta_Only_Desc_t*
 * return void:
 */
VOID Display_Setting_Welcome_Note_Destroy(VOID *pPara)
{
    UI_Normal_NoTitle_Ta_Desc_t *NormalNoTitleTaDesc = NULL;

    NormalNoTitleTaDesc = (UI_Normal_NoTitle_Ta_Desc_t *)pPara;

    Hal_Mem_Free(NormalNoTitleTaDesc->ContTa.TaTxt);
    Hal_Mem_Free(NormalNoTitleTaDesc);
}

/**
 *
 * Callback of Display_Setting_Welcome_Note, on save state
 * param (in) NormalTaOnlyDesc: UI_Normal_Ta_Only_Desc_t*
 * return void:
 */
VOID Display_Setting_Welcome_Note_SaveState(VOID *pPara)
{
    UI_Normal_NoTitle_Ta_Desc_t *NormalNoTitleTaDesc = NULL;
    const INT8 * Txt;
    NormalNoTitleTaDesc = (UI_Normal_NoTitle_Ta_Desc_t *)pPara;

    Txt = lv_textarea_get_text(NormalNoTitleTaDesc->ContTa.TextArea);
    if (0 < strlen(Txt))
    {
        Hal_Mem_Copy(NormalNoTitleTaDesc->ContTa.TaTxt, Txt, strlen(Txt) + 1);
        NormalNoTitleTaDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    }
    else
    {
        NormalNoTitleTaDesc->ContTa.TaTxt[0] = '\0';
        NormalNoTitleTaDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    }
}

/**
 *
 * Display_Setting_Welcome_Note
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Welcome_Note_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8                       nvData;
    UINT8                       nvDataArr[SETTING_MAX_WELCOME_NOTE_STR_LEN];
    char                        *txt                 = NULL;
    lv_obj_t                    *label               = NULL;
    UI_Normal_NoTitle_Ta_Desc_t *NormalNoTitleTaDesc = NULL;
    UINT8                       TxtLen;
    UINT8                       Len;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    NormalNoTitleTaDesc = (UI_Normal_NoTitle_Ta_Desc_t *)gp_SettingPhoneDisplayCurUIDesc;

    if (  (KEY_SOFTLEFT == key_val)
       || (KEY_OK == key_val))
    {
        Hal_Mem_Set(g_SettingPhoneSettingMng.WelcomeNote, 0, SETTING_MAX_WELCOME_NOTE_STR_LEN);
        txt = (INT8 *)lv_textarea_get_text(NormalNoTitleTaDesc->ContTa.TextArea);
        strcpy(g_SettingPhoneSettingMng.WelcomeNote, txt);

        Display_Setting_Welcome_Note_Opt();
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        txt    = (INT8 *)lv_textarea_get_text(NormalNoTitleTaDesc->ContTa.TextArea);
        label  = lv_obj_get_child(NormalNoTitleTaDesc->ButtonBar.ButtonR.Button, NULL);
        TxtLen = strlen(txt);
        if (0 == TxtLen)
        {       // PHONE_TEXT_ID_BACK
            UI_NV_Read_Req(NV_SECTION_UI_SETTINGS, (NV_SETTING_PHONE_SETTING_OFFSET + 8), 1, &nvData);
            g_SettingPhoneSettingMng.WelcomeNoteOn = (BOOL)nvData;

            UI_NV_Read_Req(NV_SECTION_UI_SETTINGS,
                           (NV_SETTING_PHONE_SETTING_OFFSET + 9),
                           SETTING_MAX_WELCOME_NOTE_STR_LEN,
                           nvDataArr);
            strcpy(g_SettingPhoneSettingMng.WelcomeNote, (INT8 *)nvDataArr);

            Nav_Back(ACT_ID_ANY);
        }
        else
        {       // PHONE_TEXT_ID_CLEAR
            lv_textarea_del_char(NormalNoTitleTaDesc->ContTa.TextArea);
            Len = strlen((INT8 *)lv_textarea_get_text(NormalNoTitleTaDesc->ContTa.TextArea));
            if (0 == Len)
            {
                lv_label_set_text_id(label, PHONE_TEXT_ID_BACK);
                lv_textarea_set_max_length(NormalNoTitleTaDesc->ContTa.TextArea,
                                           SETTING_MAX_WELCOME_NOTE_CHARS_NUM * 3);
            }
            else
            {
                if (1 == (TxtLen - Len))
                {
                    Len = lv_textarea_get_max_length(NormalNoTitleTaDesc->ContTa.TextArea) + 2;
                    lv_textarea_set_max_length(NormalNoTitleTaDesc->ContTa.TextArea, Len);
                }
            }
        }
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
    }
    else if ((KEY_0 <= key_val) && (KEY_9 >= key_val))
    {
        Len    = lv_textarea_get_max_length(NormalNoTitleTaDesc->ContTa.TextArea);
        TxtLen = strlen((INT8 *)lv_textarea_get_text(NormalNoTitleTaDesc->ContTa.TextArea));
        if (Len > TxtLen)
        {
            lv_textarea_add_char(NormalNoTitleTaDesc->ContTa.TextArea, key_val - KEY_0 + '0');
            lv_textarea_set_max_length(NormalNoTitleTaDesc->ContTa.TextArea, Len - 2);
            if (0 == TxtLen)
            {       // old TxtId is BACK */
                label = lv_obj_get_child(NormalNoTitleTaDesc->ButtonBar.ButtonR.Button, NULL);
                lv_label_set_text_id(label, PHONE_TEXT_ID_CLEAR);
            }
        }
    }
    else
    {
        return(0);
    }
    return(1);
}     /* Display_Setting_Welcome_Note_KeyCb */

/**
 * display Setting_Welcome_Note
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Welcome_Note(VOID)
{
    UI_Normal_NoTitle_Ta_Desc_t *NormalNoTitleTaDesc = NULL;
    Nav_Func_List_t             FuncList;

    NormalNoTitleTaDesc = (UI_Normal_NoTitle_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Ta_Desc_t));
    Hal_Mem_Set(NormalNoTitleTaDesc, 0, sizeof(UI_Normal_NoTitle_Ta_Desc_t));

    NormalNoTitleTaDesc->ContLabelTr.TxtId = LV_LANG_TXT_ID_NONE;

    NormalNoTitleTaDesc->ContTa.TaTxt = (INT8 *)Hal_Mem_Alloc(SETTING_MAX_WELCOME_NOTE_STR_LEN);
    if (TRUE == g_SettingPhoneSettingMng.WelcomeNoteOn)
    {
        Hal_Mem_Copy(NormalNoTitleTaDesc->ContTa.TaTxt,
                     g_SettingPhoneSettingMng.WelcomeNote,
                     SETTING_MAX_WELCOME_NOTE_STR_LEN);
    }
    else
    {
        NormalNoTitleTaDesc->ContTa.TaTxt[0] = '\0';
    }
    NormalNoTitleTaDesc->ContTa.TaCursorHide = FALSE;
    NormalNoTitleTaDesc->ContTa.TaAlign      = LV_LABEL_ALIGN_LEFT;

    NormalNoTitleTaDesc->ButtonBar.ButtonL.Valid = TRUE;
    NormalNoTitleTaDesc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_OPT;

    NormalNoTitleTaDesc->ButtonBar.ButtonM.Valid = FALSE;

    NormalNoTitleTaDesc->ButtonBar.ButtonR.Valid = TRUE;
    if (TRUE == g_SettingPhoneSettingMng.WelcomeNoteOn)
    {
        NormalNoTitleTaDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    }
    else
    {
        NormalNoTitleTaDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    }

    NormalNoTitleTaDesc->KeyFunc = Display_Setting_Welcome_Note_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Normal_NoTitle_Ta_Create;
    FuncList.OnCreate       = Display_Setting_Welcome_Note_CreateState;
    FuncList.OnDestroy      = Display_Setting_Welcome_Note_Destroy;
    FuncList.OnRestoreState = Display_Setting_Welcome_Note_CreateState;
    FuncList.OnSaveState    = Display_Setting_Welcome_Note_SaveState;

    gp_SettingPhoneDisplayCurUIDesc = (VOID *)NormalNoTitleTaDesc;
    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_WELCOME_NOTE, &FuncList, (VOID *)NormalNoTitleTaDesc);
    Ime_Set_GetCharLen_Func(Display_Setting_Welcome_Note_Input_Char);
}     /* Display_Setting_Welcome_Note */

VOID Display_Setting_Welcome_Note_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Welcome_Note();
    }
}

VOID Display_Setting_Flight_Mode_ON_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_ON;

        if (FALSE == g_SettingPhoneSettingMng.FlightModeOn)
        {
#if USE_LV_WLAN != 0
        hal_wlan_ui_start_flight_mode();
#endif
            Setting_Set_Flight_Mode_On(TRUE);
            Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_ON, ACT_ID_SETTING_PHONE_SETTINGS);
        }
        else
        {
            Nav_Back(ACT_ID_ANY);
        }
    }
}

VOID Display_Setting_Flight_Mode_OFF_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

        NormalContainerListDesc =
            (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;
        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId = PHONE_TEXT_ID_OFF;

        if (TRUE == g_SettingPhoneSettingMng.FlightModeOn)
        {
#if USE_LV_WLAN != 0
        hal_wlan_ui_close_flight_mode();
#endif
            Setting_Set_Flight_Mode_On(FALSE);
            Display_Setting_Done(ACT_ID_SETTING_ON_OFF, PHONE_TEXT_ID_OFF, ACT_ID_SETTING_PHONE_SETTINGS);
        }
        else
        {
            Nav_Back(ACT_ID_ANY);
        }
    }
}

/**
 * display Setting_On_Off_Flight_Mode
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Flight_Mode(VOID)
{
    UINT8 CurSetting = 0;

    if (TRUE == g_SettingPhoneSettingMng.FlightModeOn)
    {
        CurSetting = 1;
    }

    Display_Setting_On_Off(ACT_ID_SETTING_PHONE_SETTINGS,PHONE_TEXT_ID_FLIGHT_MODE,CurSetting,Display_Setting_Flight_Mode_ON_Cb,Display_Setting_Flight_Mode_OFF_Cb);
}

VOID Display_Setting_Flight_Mode_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Flight_Mode();
    }
}

/**
 *
 * Callback of Display_Setting_Phone_Settings, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Phone_Settings_Destroy(VOID *pPara)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)pPara;

    Hal_Mem_Free(NormalContainerListDesc->ContList.ContainerList);
    Hal_Mem_Free(NormalContainerListDesc);
}

/**
 *
 * Display_Setting_Phone_Settings
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Phone_Settings_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingPhoneSettingsCuContainerListUIDesc;

    if (KEY_DOWN == key_val)
    {
        NormalContainerListDesc->ContList.Index++;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_UP == key_val)
    {
        NormalContainerListDesc->ContList.Index += NormalContainerListDesc->ContList.ListContainerCnt;
        NormalContainerListDesc->ContList.Index--;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Phone_Settings
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Phone_Settings(VOID)
{
    UINT8                           i                        = 0;
    UINT8                           ListContainerCnt         = 0;
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;
    UI_Container_Base_Desc_t        *ContainerList           = NULL;
    Nav_Func_List_t                 FuncList;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(NormalContainerListDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    NormalContainerListDesc->TitleBar.TxtId      = PHONE_TEXT_ID_PHONE_SETTINGS;
    NormalContainerListDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    NormalContainerListDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    if ((FALSE == g_SettingSimStatus[MMI_MODEM_SIM_1]) && (FALSE == g_SettingSimStatus[MMI_MODEM_SIM_2]))
    {
        ListContainerCnt = 5;
    }
    else
    {
        ListContainerCnt = 6;
    }

    ContainerList = (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(ListContainerCnt * sizeof(UI_Container_Base_Desc_t));
    Hal_Mem_Set(ContainerList, 0, ListContainerCnt * sizeof(UI_Container_Base_Desc_t));

    ContainerList[i].Label.TxtId         = PHONE_TEXT_ID_LANGUAGE;
    ContainerList[i].Label.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    ContainerList[i].Label.LabelAlign    = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[i].Valid               = TRUE;
    ContainerList[i].Choise              = UI_BASE_OBJ_LABEL;
    ContainerList[i].u.Label2.TxtId      = Setting_Current_Language_To_Txtid(g_SettingPhoneSettingMng.CurrentLanguage);
    ContainerList[i].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[i].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    ContainerList[i++].ReleaseFunc       = Display_Setting_Language_Setting_Cb;

    ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_KEYGUARD_SETTINGS;
    ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[i].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[i].Valid            = TRUE;
    ContainerList[i].Choise           = UI_BASE_OBJ_NULL;
    ContainerList[i++].ReleaseFunc    = Display_Setting_Keyguard_Settings_Cb;

    if ((TRUE == g_SettingSimStatus[MMI_MODEM_SIM_1]) || (TRUE == g_SettingSimStatus[MMI_MODEM_SIM_2]))
    {
        ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_NETWORK_SEL;
        ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
        ContainerList[i].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
        ContainerList[i].Valid            = TRUE;
        ContainerList[i].Choise           = UI_BASE_OBJ_NULL;
        ContainerList[i++].ReleaseFunc    = Display_Setting_Sim_Selection_Cb;
    }

    ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_STARTUP_TONE;
    ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[i].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[i].Valid            = TRUE;
    ContainerList[i].Choise           = UI_BASE_OBJ_LABEL;
    if (TRUE == g_SettingPhoneSettingMng.StartupToneOn)
    {
        ContainerList[i].u.Label2.TxtId = PHONE_TEXT_ID_ON;
    }
    else
    {
        ContainerList[i].u.Label2.TxtId = PHONE_TEXT_ID_OFF;
    }
    ContainerList[i].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[i].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    ContainerList[i++].ReleaseFunc       = Display_Setting_Startup_Tone_Cb;

    ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_WELCOME_NOTE;
    ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[i].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[i].Valid            = TRUE;
    ContainerList[i].Choise           = UI_BASE_OBJ_NULL;
    ContainerList[i++].ReleaseFunc      = Display_Setting_Welcome_Note_Cb;

    ContainerList[i].Label.TxtId         = PHONE_TEXT_ID_FLIGHT_MODE;
    ContainerList[i].Label.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    ContainerList[i].Label.LabelAlign    = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[i].Valid               = TRUE;
    ContainerList[i].Choise              = UI_BASE_OBJ_LABEL;
    if (TRUE == g_SettingPhoneSettingMng.FlightModeOn)
    {
        ContainerList[i].u.Label2.TxtId = PHONE_TEXT_ID_ON;
    }
    else
    {
        ContainerList[i].u.Label2.TxtId = PHONE_TEXT_ID_OFF;
    }
    ContainerList[i].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[i].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    ContainerList[i].ReleaseFunc         = Display_Setting_Flight_Mode_Cb;

    NormalContainerListDesc->ContList.ListContainerCnt = ListContainerCnt;
    NormalContainerListDesc->ContList.Index            = 0;
    NormalContainerListDesc->ContList.ContainerList    = ContainerList;

    NormalContainerListDesc->ButtonBar.ButtonL.Valid = FALSE;

    NormalContainerListDesc->ButtonBar.ButtonM.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;

    NormalContainerListDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalContainerListDesc->KeyFunc = Display_Setting_Phone_Settings_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_Container_List_Create;
    FuncList.OnDestroy = Display_Setting_Phone_Settings_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_PHONE_SETTINGS, &FuncList, (VOID *)NormalContainerListDesc);
    gp_SettingPhoneSettingsCuContainerListUIDesc = (VOID *)NormalContainerListDesc;
} /* Display_Setting_Phone_Settings */

VOID Display_Setting_Phone_Settings_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if(LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Phone_Settings();
    }
}
